﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace Metriks.Parsiranje.Klase
{
    public class varInit : LOC, Renameable
    {
        public Varijabla varijabla;
        public String izraz;

        public varInit(String[] parametri)
        {
            varijabla = new Varijabla(parametri[0], parametri[1]);
            izraz = parametri[2];
        }

        public override string ispiši()
        {
            return varijabla.ispiši() + "=" + izraz+";";
        }

        public void renameVariable(string oldname, string newname)
        {
            if (varijabla.Naziv == oldname)
            {
                varijabla.Naziv = newname;
            }
            Regex r = new Regex(@"\b" + oldname + @"\b");
            izraz = r.Replace(izraz, newname);
        }
    }
}
